<?js
/*
function DbColumn (row) {
	this.name = row["name"];
	this.type = row["type"].toLowerCase();
	this.id = row["cid"];
	this.defVal = row["dflt_value"];
	this.pk = (row["pk"] == 1);
	this.allowNull = (row["notnull"] == 1);
}

function DbTable (name, db) {
	this.name = name;
	this.cols = new Array();

	var query = db.prepare("PRAGMA TABLE_INFO('" + this.name + "')");
	var results = query.exec();
	for (var i = 0; i < results.length; i++) {
		this.cols[this.cols.length] = new DbColumn(results[i]);
	}
	query.destroy();
}

DbConnection.prototype.tables = function () {
	var tables = new Array();
	var query = this.prepare("SELECT * FROM sqlite_master WHERE type = 'table'");
	var results = query.exec();
	for (var i = 0; i < results.length; i++) {
		var row = results[i];
		tables[tables.length] = new DbTable(row["tbl_name"], this);
	}
	query.destroy();
	return(tables);
}
*/

var db = new DbConnection("test01");
var tables = db.tables();
for (var i = 0; i < tables.length; i++) {
	var table = tables[i];
	response.write("Table: " + table.name + "<br>\n");
	response.write("<ul>\n");
		for (var j = 0; j < table.cols.length; j++) {
			var col = table.cols[j];
		?>
		<li>
			Name: <?js= col.name; ?><br>
			Data Type: <?js= col.type; ?><br>
			ID: <?js= col.id; ?><br>
			Default: <?js= col.defVal; ?><br>
			Is PK? <?js= col.pk ? "yes" : "no"; ?><br>
			Allow Nulls? <?js= col.allowNull ? "yes" : "no"; ?><br>
		</li>
		<?js
		}
	response.write("</ul>\n");
}

?>